package website.caidabao.blog.thymeleaf.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import website.caidabao.blog.thymeleaf.service.thymeleafService;

import java.util.HashMap;
import java.util.Map;
@Controller
@RequestMapping
public class thymeleafController {

    @Autowired
    private thymeleafService thymeleafService;
    @GetMapping("/{id}.html")
    public String toReadPage(Model model, @PathVariable("id") Long id){
        Map<String,Object> modelMap=new HashMap<>();
        modelMap.put("articleId",id);
        model.addAllAttributes(modelMap);
        this.thymeleafService.createHtml(id);
        return "item";
    }
}
